﻿
Imports elpmis

Namespace httpFunctions
    'parameters, file, any, convert to string, filename
    'return, bool, success or not
    Public Class generatecssrequestlink
        Inherits internalFunction

        Public Class parameters
            Public Const file As String = "file"
        End Class

        Private Shared m As iParametersMapping = Nothing

        Shared Sub New()
            initialMapping(m, parameters.file)
        End Sub

        Public Sub New()
            MyBase.New("css.generatelink", m)
        End Sub

        Protected Overrides Function invoke(ByVal ctx As context, ByRef output As bare_variable) As Boolean
            Dim file As String = Nothing
            If ctx.findVariableStr(parameters.file, file) Then
                Dim url As String = Nothing
                If Not isemptystring(file) Then
                    url = cssrequest.generateCssfileLinkUrl(file)
                End If
                output = New bare_variable(typeDefination.string, url)
                Return True
            Else
                raiseError("expect parameter " + parameters.file, errorHandle.errorType.user)
                Return False
            End If
        End Function
    End Class

    Public Class generatestaticrequestlink
        Inherits inputIFunction(Of String, String)

        Public Sub New()
            MyBase.New("staticrequest.generatelink")
        End Sub

        Protected Overrides Function finder() As iVariableFinder(Of String)
            Return string_finder()
        End Function

        Protected Overrides Function invoke(ByVal i As String, ByRef o As String) As Boolean
            o = staticrequest.generateStaticfileLinkUrl(i)
            Return True
        End Function

        Protected Overrides Function returnType() As typeDefination
            Return typeDefination.string
        End Function
    End Class
End Namespace